package com.das.mechanic_base.mvp.view.create.fragment;

import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.das.mechanic_base.bean.create.SelectWorkBean;
import com.das.mechanic_base.utils.X3StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hackware on 2016/9/10.
 */

public class X3ServicePagerListAdapter extends FragmentPagerAdapter {

    private List<SelectWorkBean.ShopCategoryEntityBean> mList;

    public boolean isDetection;

    public X3ServicePagerListAdapter(@NonNull FragmentManager fm, int behavior) {
        super(fm, behavior);
        mList = new ArrayList<>();
    }

    @Override
    public int getCount() {
        return X3StringUtils.isListEmpty(mList) ? 0 : mList.size();
    }

    public void changeServicePager(List<SelectWorkBean.ShopCategoryEntityBean> mList) {
        this.mList = mList;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return X3ServiceListItemFragment.newInstance(mList.get(position),isDetection);
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        super.destroyItem(container, position, object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mList.get(position).name;
    }
}
